<template>
	<view>
		<view class="listBox">
			<view class="flex list" @click="text(1)">
				<view>用户协议</view>
				<image src="../../static/info/ashArrows.png" class="ashArrows"></image>
			</view>
			<view class="flex list" @click="text(2)">
				<view>隐私条款</view>
				<image src="../../static/info/ashArrows.png" class="ashArrows"></image>
			</view>
			<view class="flex list" @click="disableUserToast">
				<view>注销账号</view>
				<image src="../../static/info/ashArrows.png" class="ashArrows"></image>
			</view>
		</view>
		<view class="quitBtn" @click="quit">退出登录</view>
	</view>
</template>

<script>
	import {
		disableUser,
	} from '../../common/api.js'
	export default {
		data() {
			return {

			}
		},
		methods: {
			text(type) {
				uni.navigateTo({
					url: '/pages/info/richText?type=' + type
				})
			},
			disableUserToast() {
				uni.showModal({
					title: '提示',
					content: '注销后该账户数据全部清空,确定注销账户?',
					success: (res) => {
						if (res.confirm) {
							this.disableUser()
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			disableUser() {
				disableUser({
					userId: uni.getStorageSync('userInfo').id
				}).then(res => {
					this.$toast(res.message)
					if (res.success) {
						setTimeout(() => {
							this.quit()
						}, 1000)
					}
				})
			},
			quit() {
				uni.clearStorageSync();
				uni.reLaunch({
					url: '/pages/info/info'
				})
			}
		}
	}
</script>

<style scoped>
	.ashArrows {
		width: 44.42rpx;
		height: 51.48rpx;
	}

	.list {
		justify-content: space-between;
		align-items: center;
		height: 70rpx;
		border-bottom: 2rpx solid #f6f6f6;
		color: #333333;
		font-size: 30rpx;
		font-weight: 400;
	}

	.list:nth-child(3) {
		border-bottom: none;
	}

	.listBox {
		width: 614rpx;
		height: 212rpx;
		border-radius: 28rpx;
		opacity: 1;
		background: #ffffff;
		padding: 20rpx 40rpx;
		margin: 24rpx 28rpx;
	}

	.quitBtn {
		position: absolute;
		bottom: 108rpx;
		left: 114rpx;
		width: 524rpx;
		height: 86rpx;
		border-radius: 62rpx;
		background: #d8d8d8;
		font-size: 32rpx;
		font-weight: 700;
		line-height: 86rpx;
		text-align: center;
		color: #333;
	}
</style>
<style>
	page {
		background: #f5f5f5;
	}
</style>